package com.financing.wap.service.impl;


import com.financing.wap.dao.IFpFaUserContractDao;
import com.financing.wap.dto.FpFaUserContractDTO;
import com.financing.wap.service.IFpFaUserContractService;
import com.financing.wap.util.DTOdateSetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * fp_fa_user_contract  
 * 理财师-合同管理 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Repository("fpFaUserContractService")
public class FpFaUserContractServiceImpl implements IFpFaUserContractService {

	@Autowired
	private IFpFaUserContractDao fpFaUserContractDao;

	@Override
	public int insert(FpFaUserContractDTO fpFaUserContract) throws SQLException {
		DTOdateSetUtil.setCreateInfo(fpFaUserContract);
		DTOdateSetUtil.setUpdateInfo(fpFaUserContract);
		fpFaUserContract.setDeleteTag("1");
		return fpFaUserContractDao.insert(fpFaUserContract);
	}

	@Override
	public void update(FpFaUserContractDTO fpFaUserContract) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpFaUserContract);
		fpFaUserContractDao.update(fpFaUserContract);
	}

	@Override
	public void updateForce(FpFaUserContractDTO fpFaUserContract) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(fpFaUserContract);
		fpFaUserContractDao.updateForce(fpFaUserContract);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		fpFaUserContractDao.delete(id);
	}
	
	@Override
	public List<FpFaUserContractDTO> queryList(FpFaUserContractDTO fpFaUserContract) throws SQLException {
		return fpFaUserContractDao.queryList(fpFaUserContract);
	}

	@Override
	public int queryListCount(FpFaUserContractDTO fpFaUserContract) throws SQLException {
		return fpFaUserContractDao.queryListCount(fpFaUserContract);
	}

	@Override
	public FpFaUserContractDTO loadById(Integer id) throws SQLException {
		return fpFaUserContractDao.loadById(id);
	}
 	@Override
	public FpFaUserContractDTO queryListGetFirst(FpFaUserContractDTO fpFaUserContract)
			throws SQLException {
		 List<FpFaUserContractDTO> queryList = queryList(fpFaUserContract);
		 if(queryList==null||queryList.size()==0){
			 return new FpFaUserContractDTO();
		 }
		 return queryList.get(0);
	}
}
